Fix key-chord handling
authorJustin Burkett <justin@burkett.cc>
Thu, 9 Dec 2021 04:57:20 +0000 (23:57 -0500)
committerJustin Burkett <justin@burkett.cc>
Thu, 9 Dec 2021 13:17:12 +0000 (08:17 -0500)
It turns out we don't need to do anything too tricky for key-chords, because
this-single-command-raw-keys returns the correct key-sequence

Fixes #254

which-key.el

index 0fa2fa39ad7430cb706c6765af66adf08ad3dd1c..edbad7a36879dcbf1bf9307fafb7268c023707ae 100644 (file)
@@ -2588,22 +2588,11 @@ Finally, show the buffer."
 (defun which-key--this-command-keys ()
   "Version of `this-single-command-keys' corrected for key-chords and god-mode."
   (let ((this-command-keys (this-single-command-keys)))
-    (when (and (equal this-command-keys [key-chord])
+    (when (and (vectorp this-command-keys)
+               (> (length this-command-keys) 0)
+               (eq (aref this-command-keys 0) 'key-chord)
                (bound-and-true-p key-chord-mode))
-      (setq this-command-keys
-            (condition-case nil
-                (let ((rkeys (recent-keys)))
-                  (vector 'key-chord
-                          ;; Take the two preceding the last one, because the
-                          ;; read-event call in key-chord seems to add a
-                          ;; spurious key press to this list. Note this is
-                          ;; different from guide-key's method which didn't work
-                          ;; for me.
-                          (aref rkeys (- (length rkeys) 3))
-                          (aref rkeys (- (length rkeys) 2))))
-              (error (progn
-                       (message "which-key error in key-chord handling")
-                       [key-chord])))))
+      (setq this-command-keys (this-single-command-raw-keys)))
     (when (and which-key--god-mode-support-enabled
                (bound-and-true-p god-local-mode)
                (eq this-command 'god-mode-self-insert))